import React from 'react';
import dynamic from 'dva/dynamic';
import { Route } from 'dva/router';
import { isToken } from '../utils/judgmentEquipment.js'

export default function balanceRoute(app) {
    const Login = dynamic({
      app,
      models: () => {
        return [
          import(/* webpackChunkName: "loginModel" */'../models/login/loginModel'),
        ];
      },
      component: () => import(/* webpackChunkName: "login" */'../routes/login/login'),
    });

    const Balance = dynamic({
        app,
        models: () => {
            return [
                import(/* webpackChunkName: "balanceModel" */'../models/balance/balanceModel'),
            ];
        },
        component: () => import(/* webpackChunkName: "balance" */'../routes/balance/balance'),
    });

    const Security = dynamic({
        app,
        models: () => {
            return [
                import(/* webpackChunkName: "balanceModel" */'../models/balance/balanceModel'),
            ];
        },
        component: () => import(/* webpackChunkName: "security" */'../routes/balance/security'),
    });

    const AccountManagement = dynamic({
        app,
        models: () => {
            return [
                import(/* webpackChunkName: "balanceModel" */'../models/balance/balanceModel'),
                import(/* webpackChunkName: "balanceModel" */'../models/my/myModel'),
            ];
        },
        component:()=>import(/* webpackChunkName: "accountManagement" */'../routes/balance/accountManagement'),
    });

    const AddressList = dynamic({
        app,
        models: () => {
            return [
                import(/* webpackChunkName: "balanceModel" */'../models/balance/balanceModel'),
            ];
        },
        component:()=>import(/* webpackChunkName: "addressList" */'../routes/balance/addressList'),
    });

    const EditAddress = dynamic({
        app,
        models: () => {
            return [
                import(/* webpackChunkName: "balanceModel" */'../models/balance/balanceModel'),
            ];
        },
        component:()=>import(/* webpackChunkName: "editAddress" */'../routes/balance/editAddress'),
    });

    const MakeName = dynamic({
        app,
        models: () => {
            return [
                import(/* webpackChunkName: "balanceModel" */'../models/balance/balanceModel'),
            ];
        },
        component:()=>import(/* webpackChunkName: "makeName" */'../routes/balance/makeName'),
    });
    const MyInvoice = dynamic({
        app,
        models: () => {
            return [
                import(/* webpackChunkName: "balanceModel" */'../models/balance/balanceModel'),
                import(/* webpackChunkName: "myModel" */'../models/my/myModel'),
                import(/* webpackChunkName: "myModel" */'../models/inVoice/inVoiceModel'),
            ];
        },
        component:()=>import(/* webpackChunkName: "myInvoice" */'../routes/balance/myInvoice'),
    });
    const Invoice = dynamic({
        app,
        models: () => {
            return [
                import(/* webpackChunkName: "balanceModel" */'../models/inVoice/inVoiceModel'),
                import(/* webpackChunkName: "balanceModel" */'../models/balance/balanceModel'),
                import(/* webpackChunkName: "myModel" */'../models/my/myModel'),
            ];
        },
        component:()=>import(/* webpackChunkName: "myInvoice" */'../routes/invoice/invoice'),
    });
    const MyFeedback = dynamic({
        app,
        models: () => {
            return [
                import('../models/balance/balanceModel'),
                import(/* webpackChunkName: "orderListModel" */'../models/orderList/orderListModel'),
            ];
        },
        component:()=>import('../routes/balance/myFeedback'),
    });
    const MyPhone = dynamic({
        app,
        models: () => {
            return [
                import('../models/balance/balanceModel'),
            ];
        },
        component:()=>import('../routes/balance/myPhone'),
    });
    const My = dynamic({
        app,
        models: () => {
            return [
                import('../models/balance/balanceModel'),
            ];
        },
        component:()=>import('../routes/balance/aboutLM'),
    });
    const BindPhone = dynamic({
        app,
        models: () => {
            return [
                import('../models/balance/balanceModel'),
            ];
        },
        component:()=>import('../routes/balance/BindPhone'),
    });
    return (
        [
            <Route key="/balance" exact path="/balance/:data" children={(props) => isToken() ? <Balance {...props}/>  : <Login {...props} /> }/>,
            <Route key="/addressList" exact path="/addressList" children={(props) => isToken() ? <AddressList {...props}/>  : <Login {...props} /> }/>,
            <Route key="/security" exact path="/security/:data" children={(props) => isToken() ? <Security {...props}/>  : <Login {...props} /> }/>,
            <Route key="/makeName" exact path="/makeName/:data" children={(props) => isToken() ? <MakeName {...props}/>  : <Login {...props} /> }/>,
            <Route key="/editAddress" exact path="/editAddress/:data" children={(props) => isToken() ? <EditAddress {...props}/>  : <Login {...props} /> }/>,
            <Route key="/accountManagement" exact path="/accountManagement" children={(props) => isToken() ? <AccountManagement {...props}/>  : <Login {...props} /> }/>,
            <Route key="/invoice" path="/invoice/:invId?" component={Invoice}/>,
            <Route key="/myInvoice" exact path="/myInvoice" component={MyInvoice}/>,
            <Route key="/myFeedback" exact path="/myFeedback" component={MyFeedback}/>,
            <Route key="/myPhone" exact path="/myPhone/:data/:link?" component={MyPhone}/>,
            <Route key="/AboutLM" exact path="/aboutLM" component={My}/>,
            <Route key="/BuildPhone" exact path="/bindPhone" component={BindPhone}/>,
        ]
    );
}
